<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
          "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>QUnit for X.509 Certificate 'x509.js'</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="qunit.js"></script>
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />

<script src="../ext/cj/cryptojs-312-core-fix.js"></script>
<script src="../ext/cj/x64-core.js"></script>
<script src="../ext/cj/cipher-core_min.js"></script>
<script src="../ext/cj/aes_min.js"></script>
<script src="../ext/cj/tripledes_min.js"></script>
<script src="../ext/cj/enc-base64_min.js"></script>
<script src="../ext/cj/md5_min.js"></script>
<script src="../ext/cj/sha1_min.js"></script>
<script src="../ext/cj/sha256_min.js"></script>
<script src="../ext/cj/sha224_min.js"></script>
<script src="../ext/cj/sha512_min.js"></script>
<script src="../ext/cj/sha384_min.js"></script>
<script src="../ext/cj/ripemd160_min.js"></script>
<script src="../ext/cj/hmac_min.js"></script>
<script src="../ext/cj/pbkdf2_min.js"></script>

<script src="../ext/yahoo.js"></script>
<script src="../ext/jsbn.js"></script>
<script src="../ext/jsbn2.js"></script>
<script src="../ext/prng4.js"></script>
<script src="../ext/rng.js"></script>
<script src="../ext/rsa.js"></script>
<script src="../ext/rsa2.js"></script>
<script src="../ext/base64.js"></script>
<script src="../ext/ec.js"></script>
<script src="../ext/ec-patch.js"></script>

<script src="../src/crypto-1.1.js"></script>
<script src="../src/asn1hex-1.1.js"></script>
<script src="../src/rsapem-1.1.js"></script>
<script src="../src/rsasign-1.2.js"></script>
<script src="../src/x509-1.1.js"></script>
<script src="../src/asn1-1.0.js"></script>
<script src="../src/asn1x509-1.0.js"></script>
<script src="../src/base64x-1.1.js"></script>
<script src="../src/keyutil-1.0.js"></script>
<script src="../src/dsa-2.0.js"></script>
<script src="../src/ecdsa-modified-1.0.js"></script>
<script src="../src/ecparam-1.0.js"></script>

<script type="text/javascript">
$(document).ready(function(){

// **** DATA **********

// z2 self
  var sCer1PEM = "" +
"-----BEGIN CERTIFICATE-----\n" + 
"MIIBqDCCAVKgAwIBAgIJAJ53Xn2fQ6vJMA0GCSqGSIb3DQEBBQUAMBoxCzAJBgNV\n" + 
"BAYTAkpQMQswCQYDVQQKEwJ6MjAeFw0xMDA1MzEwNjE3NTZaFw0yMDA1MjgwNjE3\n" + 
"NTZaMBoxCzAJBgNVBAYTAkpQMQswCQYDVQQKEwJ6MjBcMA0GCSqGSIb3DQEBAQUA\n" + 
"A0sAMEgCQQC5sAMpUF/i7WDsVondzfW5TQWrQW4WQ7HKP5b8Ry7rH2LtR2iX8Vmu\n" + 
"mLfzrezseXHetfZNmiWQHE3HpJdy5aArAgMBAAGjezB5MB0GA1UdDgQWBBS7MIUo\n" + 
"gYmDIf2DOqOcwYCKCb3GjDBKBgNVHSMEQzBBgBS7MIUogYmDIf2DOqOcwYCKCb3G\n" + 
"jKEepBwwGjELMAkGA1UEBhMCSlAxCzAJBgNVBAoTAnoyggkAnndefZ9Dq8kwDAYD\n" + 
"VR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAFhZ88q7ZS7THEcPJ8ogQ+78nyAn\n" + 
"DN7F1FsLp7jE9oM3kYQl6KYy0pwch6Wd6ypW86pel4JFOEr+LnVGODaoxFE=\n" + 
"-----END CERTIFICATE-----\n";

  var sCer1B64 = "MIIBqDCCAVKgAwIBAgIJAJ53Xn2fQ6vJMA0GCSqGSIb3DQEBBQUAMBoxCzAJBgNVBAYTAkpQMQswCQYDVQQKEwJ6MjAeFw0xMDA1MzEwNjE3NTZaFw0yMDA1MjgwNjE3NTZaMBoxCzAJBgNVBAYTAkpQMQswCQYDVQQKEwJ6MjBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQC5sAMpUF/i7WDsVondzfW5TQWrQW4WQ7HKP5b8Ry7rH2LtR2iX8VmumLfzrezseXHetfZNmiWQHE3HpJdy5aArAgMBAAGjezB5MB0GA1UdDgQWBBS7MIUogYmDIf2DOqOcwYCKCb3GjDBKBgNVHSMEQzBBgBS7MIUogYmDIf2DOqOcwYCKCb3GjKEepBwwGjELMAkGA1UEBhMCSlAxCzAJBgNVBAoTAnoyggkAnndefZ9Dq8kwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAFhZ88q7ZS7THEcPJ8ogQ+78nyAnDN7F1FsLp7jE9oM3kYQl6KYy0pwch6Wd6ypW86pel4JFOEr+LnVGODaoxFE=";

  var hCer1 = "308201a830820152a0030201020209009e775e7d9f43abc9300d06092a864886f70d0101050500301a310b3009060355040613024a50310b3009060355040a13027a32301e170d3130303533313036313735365a170d3230303532383036313735365a301a310b3009060355040613024a50310b3009060355040a13027a32305c300d06092a864886f70d0101010500034b003048024100b9b00329505fe2ed60ec5689ddcdf5b94d05ab416e1643b1ca3f96fc472eeb1f62ed476897f159ae98b7f3adecec7971deb5f64d9a25901c4dc7a49772e5a02b0203010001a37b3079301d0603551d0e04160414bb30852881898321fd833aa39cc1808a09bdc68c304a0603551d23044330418014bb30852881898321fd833aa39cc1808a09bdc68ca11ea41c301a310b3009060355040613024a50310b3009060355040a13027a328209009e775e7d9f43abc9300c0603551d13040530030101ff300d06092a864886f70d01010505000341005859f3cabb652ed31c470f27ca2043eefc9f20270cdec5d45b0ba7b8c4f68337918425e8a632d29c1c87a59deb2a56f3aa5e978245384afe2e75463836a8c451";

  var sCer2PEM = "" +
"-----BEGIN CERTIFICATE-----\n" + 
"MIIBvTCCASYCCQD55fNzc0WF7TANBgkqhkiG9w0BAQUFADAjMQswCQYDVQQGEwJK\n" + 
"UDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwHhcNMTAwNTI4MDIwODUxWhcNMjAwNTI1\n" + 
"MDIwODUxWjAjMQswCQYDVQQGEwJKUDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwgZ8w\n" + 
"DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANGEYXtfg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f9e5f373734585ed300d06092a864886f70d01010505003023310b3009060355040613024a5031143012060355040a130b30302d544553542d525341301e170d3130303532383032303835315a170d3230303532353032303835315a3023310b3009060355040613024a5031143012060355040a130b30302d544553542d52534130819f300d06092a864886f70d010101050003818d0030818902818100d184617b5f8034655944839f785a63835555088a23d0b34e1a2e6bdf83c49ba2b1ecb398105eed1a21d513ea76f9ad3879843db27e91765885ba33ccf45b1461c227205f08bcd07d5a2cf7fa9443cf2ef376f448503630699059002546d2f2eba124478ac34704e3d83cd1e041178042a922fa3c541b3fdfeb072c5dc44a00210203010001300d06092a864886f70d010105050003818100119ea65c516adc0cdf6aa587982cb50118e56ae6006bc6665059cb9b47a683d76454127adda12a01186da24e9b0d00f3489c622e908417a1b86ff36ffccfcc2f284ff8ea0e4e611331e80055032aef5721a1527238513906d41ae8cfe508710ec9ae5051fa111761c5f448d1178e0adce2bebb78af4d28f7cf08eda6e758e57a";

  var sCer3PEM = "" + // z0512.cer
"-----BEGIN CERTIFICATE-----\n" + 
"MIIBqDCCAVKgAwIBAgIJAJ53Xn2fQ6vJMA0GCSqGSIb3DQEBBQUAMBoxCzAJBgNV\n" + 
"BAYTAkpQMQswCQYDVQQKEwJ6MjAeFw0xMDA1MzEwNjE3NTZaFw0yMDA1MjgwNjE3\n" + 
"NTZaMBoxCzAJBgNVBAYTAkpQMQswCQYDVQQKEwJ6MjBcMA0GCSqGSIb3DQEBAQUA\n" + 
"A0sAMEgCQQC5sAMpUF/i7WDsVondzfW5TQWrQW4WQ7HKP5b8Ry7rH2LtR2iX8Vmu\n" + 
"mLfzrezseXHetfZNmiWQHE3HpJdy5aArAgMBAAGjezB5MB0GA1UdDgQWBBS7MIUo\n" + 
"gYmDIf2DOqOcwYCKCb3GjDBKBgNVHSMEQzBBgBS7MIUogYmDIf2DOqOcwYCKCb3G\n" + 
"jKEepBwwGjELMAkGA1UEBhMCSlAxCzAJBgNVBAoTAnoyggkAnndefZ9Dq8kwDAYD\n" + 
"VR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAANBAFhZ88q7ZS7THEcPJ8ogQ+78nyAn\n" + 
"DN7F1FsLp7jE9oM3kYQl6KYy0pwch6Wd6ypW86pel4JFOEr+LnVGODaoxFE=\n" + 
"-----END CERTIFICATE-----\n";

  var hSig3 = "" + 
"a30ea363514246b686a25529e6446d79ed3081b9709c6213f0611a495456b5b5\n" + 
"6efb33e92ad1c00348c84c6335d01425a1033e0c5006b377ab0d6b34c9322d62\n";

// _gitpg/jsrsasign/test/eckey/k1.self.cer
var k1CertPEM = "" +
"-----BEGIN CERTIFICATE-----\n" +
"MIIBfDCCASGgAwIBAgIJAKbxELQvSUDNMAoGCCqGSM49BAMCMBoxCzAJBgNVBAYT\n" +
"AlVTMQswCQYDVQQKDAJLMTAeFw0xMzA3MTQwMjE3MTdaFw0yMzA3MTIwMjE3MTda\n" +
"MBoxCzAJBgNVBAYTAlVTMQswCQYDVQQKDAJLMTBZMBMGByqGSM49AgEGCCqGSM49\n" +
"AwEHA0IABKAVMqPAkABT3mD77+/MpYeTMBWY0wi0Hm9ONk44jCcRvvQyxZkUjJQU\n" +
"PU/0bCy3Pj5qQdfu8jwEfqEeYGZ95CWjUDBOMB0GA1UdDgQWBBTIR74yfMz/Y4hw\n" +
"dXSW4r42bESo/DAfBgNVHSMEGDAWgBTIR74yfMz/Y4hwdXSW4r42bESo/DAMBgNV\n" +
"HRMEBTADAQH/MAoGCCqGSM49BAMCA0kAMEYCIQDfAcS/WKBrP6JBgksQVpp4jdq4\n" +
"C53Yu4F5NkaMgthAHgIhANGRdWAP1QdW9l6tiglQwdqJs4T0e8+NYv+RcAb3VYwn\n" +
"-----END CERTIFICATE-----\n";
var k1CertHex = pemtohex(k1CertPEM);

// _test/z1.self.sha1.cer
var Z1SELFSHA1CER = (function() {/*
-----BEGIN CERTIFICATE-----
MIIBfzCCASmgAwIBAgIBATANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJKUDEQ
MA4GA1UECgwHWjEtU0hBMTAeFw0xNzAzMTIxMjEyNDBaFw0yNzAzMTIxMjEyNDBa
MB8xCzAJBgNVBAYTAkpQMRAwDgYDVQQKDAdaMS1TSEExMFwwDQYJKoZIhvcNAQEB
BQADSwAwSAJBAOhmTdK0BSkSFWjzs5vJemLnujwJur3E8NzY35DreQubtkWitw4x
EnR7TTxBtRQkiVEV/viPedQ+rlsaTjUY/VkCAwEAAaNQME4wHQYDVR0OBBYEFMVH
PuIAyOetcAPf9UILjN30wg4VMB8GA1UdIwQYMBaAFMVHPuIAyOetcAPf9UILjN30
wg4VMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADQQCy93M5Rgj8xCFw+14v
X51SLU2/L2J5jR4ZQpTiSqfgEzdWu47WjUIcLk3RTkAi3azrP4DA3CS/8yuM3vaF
Aye2
-----END CERTIFICATE-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

var Z1SELFSHA256CER = (function() {/*
-----BEGIN CERTIFICATE-----
MIIBgzCCAS2gAwIBAgIBATANBgkqhkiG9w0BAQsFADAhMQswCQYDVQQGEwJKUDES
MBAGA1UECgwJWjEtU0hBMjU2MB4XDTE3MDMxMjEyMTMwMVoXDTI3MDMxMjEyMTMw
MVowITELMAkGA1UEBhMCSlAxEjAQBgNVBAoMCVoxLVNIQTI1NjBcMA0GCSqGSIb3
DQEBAQUAA0sAMEgCQQDoZk3StAUpEhVo87ObyXpi57o8Cbq9xPDc2N+Q63kLm7ZF
orcOMRJ0e008QbUUJIlRFf74j3nUPq5bGk41GP1ZAgMBAAGjUDBOMB0GA1UdDgQW
BBTFRz7iAMjnrXAD3/VCC4zd9MIOFTAfBgNVHSMEGDAWgBTFRz7iAMjnrXAD3/VC
C4zd9MIOFTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA0EAlqL5D9vB8xw5
85+FVPWvJCP9/hLamz8ELkZB5x9vaWCzH8aBitUZzVHO5YfUw2zolwGL7wl7ytWQ
7KvaskNJKA==
-----END CERTIFICATE-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

var Z1PUBP8 = (function() {/*
-----BEGIN PUBLIC KEY-----
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAOhmTdK0BSkSFWjzs5vJemLnujwJur3E
8NzY35DreQubtkWitw4xEnR7TTxBtRQkiVEV/viPedQ+rlsaTjUY/VkCAwEAAQ==
-----END PUBLIC KEY-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

var Z2PUBP8 = (function() {/*
-----BEGIN PUBLIC KEY-----
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAOtpGHibL8Ue+MXPPufkcrNES40rCT5L
RIU9MjTZ8/7owG5bAsiFA9Xxh3uZK1T5QA64jNJVbp2ojHAtNyWPuwsCAwEAAQ==
-----END PUBLIC KEY-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

var D1SELFSHA1CER = (function() {/*
-----BEGIN CERTIFICATE-----
MIICyzCCAoqgAwIBAgIJAJjYW2dPMfAEMAkGByqGSM44BAMwHzELMAkGA1UEBhMC
VVMxEDAOBgNVBAoMB0QxLVNIQTEwHhcNMTcwMzEyMTUyODQ1WhcNMjcwMzEwMTUy
ODQ1WjAfMQswCQYDVQQGEwJVUzEQMA4GA1UECgwHRDEtU0hBMTCCAbcwggErBgcq
hkjOOAQBMIIBHgKBgQCe0yehJAfI0tyaa5NZ+8SPKjF1BPM7SGYcSwN3j1W4GK8h
koW7zfpg9j+W9cPAZzjXJDKjb0bWSQoP5wI4UXZx56vbQwxP+3Shf7bQzs7uKP3b
SSc7zRZaUg5Klxe00n7wbzQX32qeoto1BY8RmudqyAlaLEXuV2w9/oJT80SaTwIV
AIMhJMMYgpj41t0a2EEhwu8zpdUrAoGAcRrEBTuvUCqgoJq8t69yiFSV4e+w3hKd
k8e7FvDkuAoaENBAntUrzQ3wtVEfbgj3RxVRfpQG7dRdePDvFdkrJ+85jqe/k2X6
E1kTIhSfqEY1GH2id/FcvIyaKEI/6yMyIeXRrTbZJtLh4Mdw803ASmFvVWhSIqmx
z0+Oz4fBm34DgYUAAoGBAIyv2WVM5RgY4VRhO9CxTul0+9/8WhmALEMBMCvIVNXh
fa8NZ0Wkqqjkb/lrV8iTcfpyzKEqIkiCFkXR/3WGmiVJrX/REM7v6lYW0AvllBA2
4aLYe7zwv75sOx4Yug07OvbTS6z2EycKC19nx4Zo5LpbPsCqKOdi6h+fLgFn4FI7
o1AwTjAdBgNVHQ4EFgQUsKi1stHnpSkadC6m7g8c8NHUW0owHwYDVR0jBBgwFoAU
sKi1stHnpSkadC6m7g8c8NHUW0owDAYDVR0TBAUwAwEB/zAJBgcqhkjOOAQDAzAA
MC0CFQCCRGKq1Su7OeCjIYkRL3LMGZ5D/gIUXU+jbIAYpHVW+b0kDCc6FgWIr/4=
-----END CERTIFICATE-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

var D1SELFSHA256CER = (function() {/*
-----BEGIN CERTIFICATE-----
MIICxDCCAoKgAwIBAgIJAP2Mxo43IyYSMAsGCWCGSAFlAwQDAjAaMQswCQYDVQQG
EwJVUzELMAkGA1UECgwCRDEwHhcNMTMxMDAyMTUwNDQ0WhcNMjMwOTMwMTUwNDQ0
WjAaMQswCQYDVQQGEwJVUzELMAkGA1UECgwCRDEwggG3MIIBKwYHKoZIzjgEATCC
AR4CgYEAntMnoSQHyNLcmmuTWfvEjyoxdQTzO0hmHEsDd49VuBivIZKFu836YPY/
lvXDwGc41yQyo29G1kkKD+cCOFF2ceer20MMT/t0oX+20M7O7ij920knO80WWlIO
SpcXtNJ+8G80F99qnqLaNQWPEZrnasgJWixF7ldsPf6CU/NEmk8CFQCDISTDGIKY
+NbdGthBIcLvM6XVKwKBgHEaxAU7r1AqoKCavLevcohUleHvsN4SnZPHuxbw5LgK
GhDQQJ7VK80N8LVRH24I90cVUX6UBu3UXXjw7xXZKyfvOY6nv5Nl+hNZEyIUn6hG
NRh9onfxXLyMmihCP+sjMiHl0a022SbS4eDHcPNNwEphb1VoUiKpsc9Pjs+Hw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gUjs=
-----END PUBLIC KEY-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

var D2PUBP8 = (function() {/*
-----BEGIN PUBLIC KEY-----
MIIBtjCCASsGByqGSM44BAEwggEeAoGBAIU7AWsexnwziTkgb2j4+fwIRXJcEfi7
yh9o0e56i/HrmaprEYYqD8IqWap2WkBVAWcc8L4mMl4dhqt9aniD9R49JLYpA3Yk
rKhVQZYU5mrL59xRha2fFP3mL6e04nqKoBZr6cCrBCEk64cMasBJf0l3oyB1tgMI
6EZZb8DDbDC3AhUA7SnQBVZ7sS9SD8LsvaAUNx0dkb8CgYB+7V3haRlKx+01mG2K
FWg2AovpfsIkIawal/RHYXcRvtaj3py3RScMxKzWN9wGFkmuGcxE29y1ZPczhhEE
H12q7iW7i+6msrlTplRpWqx5hA6o++U81BL8siBYU33VmY+KWveSzt75qXuA+NvU
/PVPrArRnOeGsFSfXcelYI+tMAOBhAACgYB1a7jeDsOpglsakm3aKdxsKeH07Qo1
mYmU0jRQ+G1deKXZ3uwJaqpv0a2r3CsGCjmRF7NOxGBAphGEGjjtUFm6+5vg2qYs
mc0xehOYf9LnmO0J923FZpxti1ffwWD66MnWfr4+z5Q2prVdd22M/Ejp3Ps4WOiN
WF7tfRe794Oj/g==
-----END PUBLIC KEY-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

var K1SELFSHA1CER = (function() {/*
-----BEGIN CERTIFICATE-----
MIIBhTCCASugAwIBAgIJAPdh9mPOI3jtMAoGCCqGSM49BAMCMB8xCzAJBgNVBAYT
AlVTMRAwDgYDVQQKDAdLMS1TSEExMB4XDTE3MDMxMjE1NDk1N1oXDTI3MDMxMDE1
NDk1N1owHzELMAkGA1UEBhMCVVMxEDAOBgNVBAoMB0sxLVNIQTEwWTATBgcqhkjO
PQIBBggqhkjOPQMBBwNCAASgFTKjwJAAU95g++/vzKWHkzAVmNMItB5vTjZOOIwn
Eb70MsWZFIyUFD1P9Gwstz4+akHX7vI8BH6hHmBmfeQlo1AwTjAdBgNVHQ4EFgQU
yEe+MnzM/2OIcHV0luK+NmxEqPwwHwYDVR0jBBgwFoAUyEe+MnzM/2OIcHV0luK+
NmxEqPwwDAYDVR0TBAUwAwEB/zAKBggqhkjOPQQDAgNIADBFAiEApQKaiAlwj2q+
KGv0H1IDDx71jK8R6uhLjE8Dr2VlTjQCIEftSsdF4/jbvK5EazbSr+2wXUEXiwuP
VC33skJZKFrJ
-----END CERTIFICATE-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

var K1SELFSHA256CER = (function() {/*
-----BEGIN CERTIFICATE-----
MIIBfDCCASGgAwIBAgIJAKbxELQvSUDNMAoGCCqGSM49BAMCMBoxCzAJBgNVBAYT
AlVTMQswCQYDVQQKDAJLMTAeFw0xMzA3MTQwMjE3MTdaFw0yMzA3MTIwMjE3MTda
MBoxCzAJBgNVBAYTAlVTMQswCQYDVQQKDAJLMTBZMBMGByqGSM49AgEGCCqGSM49
AwEHA0IABKAVMqPAkABT3mD77+/MpYeTMBWY0wi0Hm9ONk44jCcRvvQyxZkUjJQU
PU/0bCy3Pj5qQdfu8jwEfqEeYGZ95CWjUDBOMB0GA1UdDgQWBBTIR74yfMz/Y4hw
dXSW4r42bESo/DAfBgNVHSMEGDAWgBTIR74yfMz/Y4hwdXSW4r42bESo/DAMBgNV
HRMEBTADAQH/MAoGCCqGSM49BAMCA0kAMEYCIQDfAcS/WKBrP6JBgksQVpp4jdq4
C53Yu4F5NkaMgthAHgIhANGRdWAP1QdW9l6tiglQwdqJs4T0e8+NYv+RcAb3VYwn
-----END CERTIFICATE-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

var K1PUBP8 = (function() {/*
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEoBUyo8CQAFPeYPvv78ylh5MwFZjT
CLQeb042TjiMJxG+9DLFmRSMlBQ9T/RsLLc+PmpB1+7yPAR+oR5gZn3kJQ==
-----END PUBLIC KEY-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

var K4PUBP8 = (function() {/*
-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEIjU/OABisr3mdxIJE4b6o2nsXvGiRNBs
RZ/j3h+wpditI6OHi+deN1VG8Uym5CdV/uBL14wDQ6yAOPWiGOH7xQ==
-----END PUBLIC KEY-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

// https://github.com/Unicon/cas-adfs-integration/blob/master/cas-server-support-wsfederation/src/test/resources/adfs-signing.crt X509v3 without ext
var ADFS_CER = (function() {/*
-----BEGIN CERTIFICATE-----
MIIC3DCCAcSgAwIBAgIQfvG8NFyPxbVHf9gz7U8TOTANBgkqhkiG9w0BAQsFADAq
MSgwJgYDVQQDEx9BREZTIFNpZ25pbmcgLSBhZGZzLmV4YW1wbGUuY29tMB4XDTE0
MDIyNjIyMDcyOVoXDTE1MDIyNjIyMDcyOVowKjEoMCYGA1UEAxMfQURGUyBTaWdu
aW5nIC0gYWRmcy5leGFtcGxlLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
AQoCggEBAJTATfLi3ZWlVemGuK576Sup3dNBD+hRs1Ki+VBk4WszR2+/UIiUkraK
VcnUgNpCrBGna1VntVmxZSGZyaLoFQq//RkLNKqRUfl5aMYBXiEa0r7sh4INRXtj
gKtBXne1ifxLMdZTtyYfOKWX6GMzi9bLyen+cIMgODivnpiFG8MuxL32ZeChC3if
uYojwgGgPb6u/o0bKjTr07GvuQyhpfwzmF/6ZYK/3a/NWJ5P1RtsUhtuFoOWJqn8
cxn4AzcJTuxKyIUEgxpWaW+iRwqPALtgr+EhXbRR/2kDnJCGxh7PEXEUkKSA7AWx
kqB6VZU+V2g5vwLWyI8Ke09h7xSZ0z8CAwEAATANBgkqhkiG9w0BAQsFAAOCAQEA
fVY/99ZPq1k/uHI+pM+sigus7Jm2wfY0y95wDK265ZuhMKEiNYdOzT9tsXGFe4Aq
9DDygixD0Zk2Ud0q3F1Y1eyxXn5JATmW6iyMtr5x/dhRnzQSZWJw0evAxC2OjHSB
i3dQwcP6fjWFA1VH9r+1HQyEangF2AyTUoRddFh7UcoxzYFfhDCyNU9xOaovXNuE
g6H9KJX41xBSLnI8cBg+rAGelXWuLVdrJ3CJ0c6WB9iDrq96vGW0HuKXgeKbq/xD
V5el1gq/hD+kqd9lVSIAR73tLyl7WC++nSpj6JLuNAzA36Cxu1dNaGscaMPgegQK
h4JQjIleD89XV2sdjwXsog==
-----END CERTIFICATE-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

// **** TEST **********

test("getPublicKeyIdx", function() {
  var x = new X509();
  x.readCertHex(hCer1);
  equal(x.getPublicKeyIdx(), 127 * 2, "check position of subject public key info.");
});

test("getPublicKeyContentIdx", function() {
  var x = new X509();
  x.readCertHex(hCer1);
  equal(x.getPublicKeyContentIdx(), 147 * 2, "check position of subject public key without encapsulation.");
});

test("readCertPEM", function() {
  var c = new X509();
  c.readCertPEM(sCer1PEM);
  equal(c.hex, hCer1, "c.hex");
});

test("readCertPEM - X509v3 without ext adfs-signing.crt", function() {
  var c = new X509();
  c.readCertPEM(ADFS_CER);
  equal(c.aExtInfo, null, "aExtInfo == null");
});

test("getPublicKey(), RSAKey.verify() integration test", function() {
  var c = new X509();
  c.readCertPEM(sCer1PEM);
  var key = c.getPublicKey();
  equal(key.verify("aaa", hSig3), true, "check sig is valid");
  equal(key.verify("aab", hSig3), false, "check sig is invalid.");
});

test("new X509(PEM).getSerialNumber/Issuer/Subject/NotBefore/NotAfter test", function() {
  var c = new X509();
  c.readCertPEM(sCer1PEM);
  equal(c.getSerialNumberHex(), "009e775e7d9f43abc9", "sn = 02");
  equal(c.getIssuerHex(), "301a310b3009060355040613024a50310b3009060355040a13027a32", "issuer");
  equal(c.getSubjectHex(), "301a310b3009060355040613024a50310b3009060355040a13027a32", "subject");
  equal(c.getNotBefore(), "100531061756Z", "notbefore");
  equal(c.getNotAfter(), "200528061756Z", "notafter");
  equal(X509.hex2dn(c.getSubjectHex()), "/C=JP/O=z2", "subjecthex2str");
  equal(c.getIssuerString(), "/C=JP/O=z2", "issuer str");
  equal(c.getSubjectString(), "/C=JP/O=z2", "subject str");
});

/*
test("hoge", function() {
  RSAKey.prototype.verifyString = _rsasign_verifyString;
  var r = new RSAKey();
  expect(4);
  equal(hex2b64, null, "check 4");
  equal(_rsasign_verifyString, null, "check 3");
  equal(r.signString, null, "check signString function");
  equal(r.verifyString, null, "check verifyString function");
});
 */

test("getPublicKeyInfoPropOfCertPEM sCer1PEM", function() {
  var r = X509.getPublicKeyInfoPropOfCertPEM(sCer1PEM);
  expect(3);
  equal(r.algoid, "2a864886f70d010101", "algoid");
  equal(r.algparam, null, "algparam");
  equal(r.keyhex, "3048024100b9b00329505fe2ed60ec5689ddcdf5b94d05ab416e1643b1ca3f96fc472eeb1f62ed476897f159ae98b7f3adecec7971deb5f64d9a25901c4dc7a49772e5a02b0203010001", "keyhex");
});

test("getPublicKeyInfoPropOfCertPEM k1(ECC)", function() {
  var r = X509.getPublicKeyInfoPropOfCertPEM(k1CertPEM);
  expect(3);
  equal(r.algoid, "2a8648ce3d0201", "algoid"); // ecPublicKey
  equal(r.algparam, "2a8648ce3d030107", "algparam"); // secp256r1
  equal(r.keyhex, "04a01532a3c0900053de60fbefefcca58793301598d308b41e6f4e364e388c2711bef432c599148c94143d4ff46c2cb73e3e6a41d7eef23c047ea11e60667de425", "keyhex");
});

test("getSignatureAlgorithmName k1(ECC)", function() {
  var x = new X509();
  x.readCertHex(k1CertHex);
  equal(x.getSignatureAlgorithmName(), "SHA256withECDSA", "k1(ECC) SHA256withECDSA");
});

test("getSignatureAlgorithmName z2(RSA)", function() {
  var x = new X509();
  x.readCertHex(hCer1);
  var r = x.getSignatureAlgorithmName();
  equal(r, "SHA1withRSA", "z2(RSA) SHA1withRSA");
});

test("getSignatureValueHex k1(ECC)", function() {
  var x = new X509();
  x.readCertHex(k1CertHex);
  equal(x.getSignatureValueHex(), "3046022100df01c4bf58a06b3fa241824b10569a788ddab80b9dd8bb817936468c82d8401e022100d19175600fd50756f65ead8a0950c1da89b384f47bcf8d62ff917006f7558c27", "k1(ECC) SHA256withECDSA");
});

test("verifySignature RSA z1.self.sha1.cer with z1.pub.p8 VALID", function() {
var pubkey = KEYUTIL.getKey(Z1PUBP8);
var x = new X509();
x.readCertPEM(Z1SELFSHA1CER);
equal(x.verifySignature(pubkey), true, "true");
});

test("verifySignature RSA z1.self.sha1.cer with z2.pub.p8 INVALID", function() {
var pubkey = KEYUTIL.getKey(Z2PUBP8);
var x = new X509();
x.readCertPEM(Z1SELFSHA1CER);
equal(x.verifySignature(pubkey), false, "false");
});

test("verifySignature RSA z1.self.sha256.cer with z1.pub.p8 VALID", function() {
var pubkey = KEYUTIL.getKey(Z1PUBP8);
var x = new X509();
x.readCertPEM(Z1SELFSHA256CER);
equal(x.verifySignature(pubkey), true, "true");
});

test("verifySignature RSA z1.self.sha256.cer with z2.pub.p8 INVALID", function() {
var pubkey = KEYUTIL.getKey(Z2PUBP8);
var x = new X509();
x.readCertPEM(Z1SELFSHA256CER);
equal(x.verifySignature(pubkey), false, "false");
});

test("verifySignature DSA d1.self.sha1.cer with d1.pub.p8 VALID", function() {
var pubkey = KEYUTIL.getKey(D1PUBP8);
var x = new X509();
x.readCertPEM(D1SELFSHA1CER);
equal(x.verifySignature(pubkey), true, "true");
});

test("verifySignature DSA d1.self.sha1.cer with d2.pub.p8 INVALID", function() {
var pubkey = KEYUTIL.getKey(D2PUBP8);
var x = new X509();
x.readCertPEM(D1SELFSHA1CER);
equal(x.verifySignature(pubkey), false, "false");
});

test("verifySignature DSA d1.self.sha256.cer with d1.pub.p8 VALID", function() {
var pubkey = KEYUTIL.getKey(D1PUBP8);
var x = new X509();
x.readCertPEM(D1SELFSHA256CER);
equal(x.verifySignature(pubkey), true, "true");
});

test("verifySignature DSA d1.self.sha256.cer with d2.pub.p8 INVALID", function() {
var pubkey = KEYUTIL.getKey(D2PUBP8);
var x = new X509();
x.readCertPEM(D1SELFSHA256CER);
equal(x.verifySignature(pubkey), false, "false");
});

test("verifySignature ECDSA k1.self.sha1.cer with k1.pub.p8 VALID", function() {
var pubkey = KEYUTIL.getKey(K1PUBP8);
var x = new X509();
x.readCertPEM(K1SELFSHA1CER);
equal(x.verifySignature(pubkey), true, "true");
});

test("verifySignature ECDSA k1.self.sha1.cer with k4.pub.p8 INVALID", function() {
var pubkey = KEYUTIL.getKey(K4PUBP8);
var x = new X509();
x.readCertPEM(K1SELFSHA1CER);
equal(x.verifySignature(pubkey), false, "false");
});

test("verifySignature ECDSA k1.self.sha256.cer with k1.pub.p8 VALID", function() {
var pubkey = KEYUTIL.getKey(K1PUBP8);
var x = new X509();
x.readCertPEM(K1SELFSHA256CER);
equal(x.verifySignature(pubkey), true, "true");
});

test("verifySignature ECDSA k1.self.sha256.cer with k4.pub.p8 INVALID", function() {
var pubkey = KEYUTIL.getKey(K4PUBP8);
var x = new X509();
x.readCertPEM(K1SELFSHA256CER);
equal(x.verifySignature(pubkey), false, "false");
});

});
</script>
  
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">test markup</div>

<p>
<a href="../">TOP</a> | 
<a href="index.html">TEST INDEX</a> | 
<a href="qunit-do-x509.html">x509</a> | 
<a href="qunit-do-x509-ext.html">x509-ext</a> | 
<a href="qunit-do-x509-key.html">x509-key</a> | 
<a href="qunit-do-x509-kid.html">x509-kid</a> | 
<a href="qunit-do-x509-getinfo.html">x509-getinfo</a> | 
<a href="qunit-do-x509-v1.html">x509-v1</a> | 
</p>

</body>
<center><p>&copy; 2010-2017 Kenji Urushima</p></center>
</html>

